<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8" />
    <title>2022疫情管理系统</title>
    <!-- 引入刚刚下载的 ECharts 文件 -->
    <script th:src="@{/echarts/echarts.min.js}"></script>
    <script th:src="@{/echarts/china.js}"></script>
    <script th:src="@{/echarts/jquery-1.11.1.min.js}"></script>
    <!-- 注意：如果你直接复制所有代码到本地，上述 JS 路径需要改成你本地的 -->
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}" media="all">
    <script th:src="@{/layui/layui.js}" charset="utf-8"></script>

</head>
<body class="childrenBody">
    <!--layui公共区域-->
    <!--<div th:replace="common :: menu"></div>-->
    <!--<div class="layui-body">-->
    <div>
        <!--面板位置-->
        <div class="layui-bg-gray" style="padding: 30px;">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md8">
                    <div class="layui-panel">
                        <!--在线网页数据的四个按钮-->
                        <div>
                            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
                                <legend>新冠肺炎实时疫情数据展示————统计截止时间:<sapn th:text="${#dates.format(chinaTotal.updateTime,'yyyy-MM-dd HH:mm')}"></sapn></legend>
                            </fieldset>

                            <div class="layui-btn-container">
                                <button type="button" class="layui-btn layui-btn-danger layui-btn-lg" th:text="'累计确诊:'+${chinaTotal.confirm}">确诊人数</button>
                                <button type="button" class="layui-btn layui-btn-warm layui-btn-lg" th:text="'输入病例:'+${chinaTotal.input}">输入病例</button>
                                <button type="button" class="layui-btn layui-btn-lg layui-btn-lg" th:text="'治愈病例:'+${chinaTotal.heal}">治愈病例</button>
                                <button type="button" class="layui-btn layui-bg-black layui-btn-lg" th:text="'死亡人数:'+${chinaTotal.dead}">死亡人数</button>
                            </div>
                        </div>
                        <!--放入地图-->
                        <!-- 为 ECharts 准备一个定义了宽高的 DOM -->
                        <div id="main" style="width: 700px;height:600px;"></div>
                    </div>
                </div>
                <div class="layui-col-md4">
                    <div class="layui-panel">
                        <!--存放轮播图-->
                        <div class="layui-carousel" id="test1" lay-filter="test1">
                            <div carousel-item="">
                                <div><img style="height: 100%;width: 100%" th:src="@{/images/banner1.jpg}"></div>
                                <div><img style="height: 100%;width: 100%" th:src="@{/images/banner2.jpg}"></div>
                                <div><img style="height: 100%;width: 100%" th:src="@{/images/banner3.jpg}"></div>
                            </div>
                        </div>
                        <!--新闻数据-->
                        <div style="padding-top: 10px">
                            <ul  class="layui-timeline">
                                <li th:each="n : ${newsList}" class="layui-timeline-item">
                                    <i class="layui-icon layui-timeline-axis"></i>
                                    <div class="layui-timeline-content layui-text">
                                        <h3 class="layui-timeline-title" th:text="${#dates.format(n.createTime,'yyyy-MM-dd HH:mm')}">发布时间</h3>
                                        <p>
                                            <br><span class="layui-badge layui-bg-red">标题:</span><span th:text="${n.title}"></span>
                                            <br><span class="layui-badge layui-bg-green">内容:</span><span th:text="${n.content}"></span>
                                            <br><span class="layui-badge layui-bg-bule">发布者:</span><span th:text="${n.publishBy}"></span>
                                        </p>
                                    </div>
                                </li>
                                <li class="layui-timeline-item">
                                    <i class="layui-icon layui-timeline-axis"></i>
                                    <div class="layui-timeline-content layui-text">
                                        <div class="layui-timeline-title">过去</div>
                                    </div>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    <!-- 内容主体区域 -->

    </div>
    <script th:inline="none">
        //JS
        layui.use(['carousel', 'element', 'layer', 'util'], function(){
            var element = layui.element
                ,layer = layui.layer
                ,carousel = layui.carousel
                ,util = layui.util
                ,$ = layui.$;

            //头部事件
            util.event('lay-header-event', {
                //左侧菜单事件
                menuLeft: function(othis){
                    layer.msg('展开左侧菜单的操作', {icon: 0});
                }
                ,menuRight: function(){
                    layer.open({
                        type: 1
                        ,content: '<div style="padding: 15px;">处理右侧面板的操作</div>'
                        ,area: ['260px', '100%']
                        ,offset: 'rt' //右上角
                        ,anim: 5
                        ,shadeClose: true
                    });
                }
            });

            //轮播图组件
            //常规轮播
            carousel.render({
                elem: '#test1'
                ,arrow: 'always'
                ,height: '220px'
                ,width: '350px'
            });

        });
    </script>

    <script type="text/javascript" th:inline="none">
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('main'));
        var dataList = [];

        option = {
            tooltip: {
                triggerOn: "click",
                formatter: function(e, t, n) {
                    return '.5' == e.value ? e.name + "：有疑似病例" : e.seriesName + "<br />" + e.name + "：" + e.value
                }
            },
            toolbox: {
                show: true,
                orient: 'vertical',
                left: 'right',
                top: 'center',
                feature: {
                    dataView: {readOnly: false},
                    restore: {},
                    saveAsImage: {}
                }
            }, // 提供下载工具
            visualMap: {
                min: 0,
                max: 100000,
                left: 26,
                bottom: 40,
                showLabel: !0,
                text: ["高", "低"],
                pieces: [{
                    gt: 10000,
                    label: "> 10000人",
                    color: "#7f1100"
                }, {
                    gte: 1000,
                    lte: 10000,
                    label: "1000 - 10000人",
                    color: "#ff5428"
                }, {
                    gte: 100,
                    lt: 1000,
                    label: "100 - 1000人",
                    color: "#ff8c71"
                }, {
                    gt: 10,
                    lt: 100,
                    label: "10 - 100人",
                    color: "#ffd768"
                }, {
                    gt: 1,
                    lt: 10,
                    label: "1 - 10人",
                    color: "#ffffff"
                }],
                show: !0
            },
            geo: {
                map: "china",
                roam: !1,
                scaleLimit: {
                    min: 1,
                    max: 2
                },
                zoom: 1.23,
                top: 120,
                label: {
                    normal: {
                        show: !0,
                        fontSize: "14",
                        color: "rgba(0,0,0,0.7)"
                    }
                },
                itemStyle: {
                    normal: {
                        //shadowBlur: 50,
                        //shadowColor: 'rgba(0, 0, 0, 0.2)',
                        borderColor: "rgba(0, 0, 0, 0.2)"
                    },
                    emphasis: {
                        areaColor: "#f2d5ad",
                        shadowOffsetX: 0,
                        shadowOffsetY: 0,
                        borderWidth: 0
                    }
                }
            }
        };

        //发送请求
        $.ajax({
            url: "/query",
            dataType: "json",
            success: function (data) {
                for (let i in data){
                    dataList[i] = data[i];
                }
                //渲染数据
                myChart.setOption({
                    series: [
                        {
                            name: "确诊病例",
                            type: "map",
                            geoIndex: 0,
                            data: dataList
                        }
                    ]
                })
            }
        })

        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
    </script>
</body>
</html>